package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldRegionMaterialDetails;
import com.cleaningcloud.cld.service.ICldRegionMaterialDetailsService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 物资清单明细Controller
 * 
 * @author cleaningcloud
 * @date 2025-09-29
 */
@RestController
@RequestMapping("/regionMaterialDetails")
public class CldRegionMaterialDetailsController extends BaseController
{
    @Autowired
    private ICldRegionMaterialDetailsService cldRegionMaterialDetailsService;

    /**
     * 查询物资清单明细列表
     */
    @RequiresPermissions("cld:regionMaterial:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRegionMaterialDetails cldRegionMaterialDetails)
    {
        startPage();
        List<CldRegionMaterialDetails> list = cldRegionMaterialDetailsService.selectCldRegionMaterialDetailsList(cldRegionMaterialDetails);
        return getDataTable(list);
    }

    /**
     * 导出物资清单明细列表
     */
    @RequiresPermissions("cld:regionMaterial:export")
    @Log(title = "物资清单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldRegionMaterialDetails cldRegionMaterialDetails)
    {
        List<CldRegionMaterialDetails> list = cldRegionMaterialDetailsService.selectCldRegionMaterialDetailsList(cldRegionMaterialDetails);
        ExcelUtil<CldRegionMaterialDetails> util = new ExcelUtil<CldRegionMaterialDetails>(CldRegionMaterialDetails.class);
        util.exportExcel(response, list, "物资清单明细数据");
    }

    /**
     * 获取物资清单明细详细信息
     */
    @RequiresPermissions("cld:regionMaterial:query")
    @GetMapping(value = "/{regionMaterialDetailsId}")
    public AjaxResult getInfo(@PathVariable("regionMaterialDetailsId") Long regionMaterialDetailsId)
    {
        return success(cldRegionMaterialDetailsService.selectCldRegionMaterialDetailsByRegionMaterialDetailsId(regionMaterialDetailsId));
    }

    /**
     * 新增物资清单明细
     */
    @RequiresPermissions("cld:regionMaterial:add")
    @Log(title = "物资清单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRegionMaterialDetails cldRegionMaterialDetails)
    {
        return toAjax(cldRegionMaterialDetailsService.insertCldRegionMaterialDetails(cldRegionMaterialDetails));
    }

    /**
     * 修改物资清单明细
     */
    @RequiresPermissions("cld:regionMaterial:edit")
    @Log(title = "物资清单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRegionMaterialDetails cldRegionMaterialDetails)
    {
        return toAjax(cldRegionMaterialDetailsService.updateCldRegionMaterialDetails(cldRegionMaterialDetails));
    }

    /**
     * 删除物资清单明细
     */
    @RequiresPermissions("cld:regionMaterial:remove")
    @Log(title = "物资清单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regionMaterialDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] regionMaterialDetailsIds)
    {
        return toAjax(cldRegionMaterialDetailsService.deleteCldRegionMaterialDetailsByRegionMaterialDetailsIds(regionMaterialDetailsIds));
    }
}
